/**
 * \* Created with IntelliJ IDEA.
 * \* User: 冯若航
 * \* Date: 2021/5/12
 * \* Time: 2:28
 * \* To change this template use File | Settings | File Templates.
 * \* Description:
 * \
 */
public class 盛最多水的容器 {
    public int maxArea(int[] height) {
        if (height == null || height.length == 0) {
            return 0;
        }
        int l = 0,r = height.length - 1,res=0;
        while (l<r){
            int area = Math.min(height[l], height[r]) * (r - l);
            res=Math.max(res,area);
            //只移动短板即可
            if (height[l] <= height[r]) {
                l++;
            } else {
                r--;
            }
        }
        return res;
    }
}